package mutsumimod.powers;

import com.megacrit.cardcrawl.actions.common.ReducePowerAction;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.core.AbstractCreature;
import mutsumimod.MutsumiMod;
import mutsumimod.cards.custom.FourBreak;
import mutsumimod.util.damageinfo.FourBreakDamageInfo;


//即使是回合结束时减半伤害显示计算也还是会有问题，比如有两个怪物，第一个怪物不破防而第二个怪物能破防时。
//把计算的任务交给玩家了
public class BreakPower extends BasePower {
    public static final String POWER_ID = MutsumiMod.makeID(BreakPower.class.getSimpleName());

    public BreakPower(AbstractCreature owner,int amount) {
        super(POWER_ID, PowerType.DEBUFF, false, owner, amount);
    }

    public int afterAttackedToChangeDamage(DamageInfo info, int damageAmount) {
        if(damageAmount<=0||!info.type.equals(DamageInfo.DamageType.NORMAL)) {
            return damageAmount;
        }
        flash();
        return damageAmount+amount;
    }

    public void loseAmount(DamageInfo info, int damageAmount) {
        if(!owner.hasPower(PerfectPower.POWER_ID)&&damageAmount>0&&!(info instanceof FourBreakDamageInfo)) {
            addToTop(new ReducePowerAction(owner, owner, this, (amount+1)/2));
        }
    }

    @Override
    public void updateDescription() {
        this.description = DESCRIPTIONS[0] + this.amount + DESCRIPTIONS[1];
    }

}
